﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AKBGame.Object
{
    public class EventGameDetail
    {
        public List<DifficultyPoint> DifficultyPointList { get; set; }
        public List<DifficultyExpLP> DifficultyExpLPList { get; set; }

        public EventGameDetail()
        {
            DifficultyPointList = new List<DifficultyPoint>();
            DifficultyExpLPList = new List<DifficultyExpLP>();
        }

        public DifficultyPoint FindBestDifficultyPoint(int currentExp, int currentLP)
        {
            DifficultyPoint bestDifficultyPoint = null;
            double bestRatio = 0;

            foreach (DifficultyPoint difficultyPoint in DifficultyPointList)
            {
                DifficultyExpLP difficultyExpLP = DifficultyExpLPList.Single(o => o.Difficulty == difficultyPoint.Difficulty);
                double ratio;

                if (currentExp <= difficultyExpLP.Exp && currentLP > difficultyExpLP.LP)
                    ratio = difficultyPoint.Point / currentLP;

                else
                    ratio = difficultyPoint.Point / difficultyExpLP.LP;

                if (ratio > bestRatio)
                {
                    bestRatio = ratio;
                    bestDifficultyPoint = difficultyPoint;
                }
            }

            return bestDifficultyPoint;
        }

        //public int FindBestDifficultyByMode(string mode, int currentExp, int currentLP)
        //{
        //    EventGameDetailPoint eventGameDetailPoint = PointList.Single(o => o.Mode == mode);

        //    double bestRatio = 0;

        //    double hSRatio = 0;
        //    double hardRatio = 0;
        //    double normalRatio = 0;
        //    double easyRatio = 0;

        //    //HS
        //    if (currentExp <= HSExp && currentLP > HSLP)
        //        hSRatio = eventGameDetailPoint.HSPoint / currentLP;

        //    else
        //        hSRatio = eventGameDetailPoint.HSPoint / HSLP;

        //    //Hard
        //    if (currentExp <= HardExp && currentLP > HardLP)
        //        hardRatio = eventGameDetailPoint.HardPoint / currentLP;

        //    else
        //        hardRatio = eventGameDetailPoint.HardPoint / HardLP;

        //    //Normal
        //    if (currentExp <= NormalExp && currentLP > NormalLP)
        //        normalRatio = eventGameDetailPoint.NormalPoint / currentLP;

        //    else
        //        normalRatio = eventGameDetailPoint.NormalPoint / NormalLP;

        //    //Easy
        //    if (currentExp <= EasyExp && currentLP > EasyLP)
        //        easyRatio = eventGameDetailPoint.EasyPoint / currentLP;

        //    else
        //        easyRatio = eventGameDetailPoint.EasyPoint / EasyLP;

        //    double maxRatio = Math.Max(Math.Max(hSRatio, hardRatio), Math.Max(normalRatio, easyRatio));
        //    bestRatio = maxRatio;

        //    //if (hSRatio == maxRatio)
        //    //{
        //    //    bestDifficulty = "HS";
        //    //    bestLP = eventTotalGameDetail.HSLP;
        //    //    bestExp = eventTotalGameDetail.HSExp;
        //    //    bestPoint = maxHSPoint;
        //    //}
        //}
    }
}
